OPEN_CFI := -flto -fvisibility=hidden -fsanitize=cfi
CFI_LOG := -fno-sanitize-trap=cfi
OPEN_LTO := -flto
src := ./ok.c ./main.c ./not_ok.c 

all_target :=
all:

all_target += nocfi
nocfi: $(src)
	clang -g -O$(O) $(OPEN_LTO) $^ -o $@

all_target += cfi
cfi: $(src)
	clang -g -O$(O) $(OPEN_CFI) $^ -o $@

all_target += cfi_with_info
cfi_with_info: $(src)
	clang -g -O$(O) $(OPEN_CFI) $(CFI_LOG) $^ -o $@



all_dump := $(addsuffix .dump, $(all_target))
dump: $(all_target) $(all_dump)

$(all_dump): %.dump : %
	llvm-objdump -d -S $< > $@

clean:
	rm -f $(all_target) *.o $(all_dump)

all: clean dump

.PHONY: clean all dump
